<%@ page language="java"  pageEncoding="utf-8"%>
<%@ page import="java.util.Vector,com.ejoysoft.wlanyz.business.Latlng,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@ include file="../include/jsp/head.jsp"%>
<%
if(!globa.userSession.hasRight("10005"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
 
    //初始化
    Latlng  latlng0=null;
    Latlng obj=new Latlng(globa);
    //查询条件
    String  strAcName=ParamUtil.getString(request,"strAcName","").trim();
    String strAcLocation = ParamUtil.getString(request,"strAcLocation","").trim();
    	//当前页
	int intCurPage= Integer.parseInt(ParamUtil.getString(request,"strCurPage","1"));
	String tWhere=" WHERE 1=1";
	if(!strAcName.equals("")){
	 tWhere += " and acName in (select strid from ac_class_associate where classtwoac LIKE '%"+strAcName+"%')";
	}
	if(!strAcLocation.equals("")){
	 tWhere += " and acLocation LIKE '%" + strAcLocation + "%'";
	}
	String checked1 =  ParamUtil.getString(request,"checkedFlag","all"); 
	if(checked1.equals("checked")){
	  tWhere += " and checkedLocation is not null and checkedLocation <>' ' ";
	}
	else if(checked1.equals("unchecked")){
	  tWhere += " and checkedLocation is null or checkedLocation =' '";
	}
	 tWhere += " ORDER BY acName";

	//记录总数
	int intAllCount=obj.getCount(tWhere);	

	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	Vector<Latlng> vctObj=obj.list(tWhere,intStartNum,intPageSize);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	
	String exportContent = ParamUtil.getString(request,"exportContent","");
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list(tWhere,0,0);
		}
   	   	StringBuffer sb = new StringBuffer();
	    sb.append("热点,地址,系统中的经纬度,手机定位经纬度,解析后的经纬度,准确度(米)\n");
	    
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
		       String strSb = vctObj.get(i).getAcName().replace("\n","") == null? "," :vctObj.get(i).getAcName().replace("\n","")+ ",";
		       strSb += (vctObj.get(i).getAcLocation()== null || vctObj.get(i).getAcLocation().equals(""))? ",":vctObj.get(i).getAcLocation().replace("\n","") + ",";
		       strSb += (vctObj.get(i).getOriginalLocation() == null|| vctObj.get(i).getOriginalLocation().equals("")) ? "," : vctObj.get(i).getOriginalLocation().replace("\n","").replace(",","，") + ",";
		       strSb += (vctObj.get(i).getPhoneLocation() == null || vctObj.get(i).getPhoneLocation().equals(""))? "," : vctObj.get(i).getPhoneLocation().replace("\n","").replace(",","，") + ",";
		       strSb += (vctObj.get(i).getCheckedLocation() == null || vctObj.get(i).getCheckedLocation().equals(""))? "," : vctObj.get(i).getCheckedLocation().replace("\n","").replace(",","，") + ",";
		       strSb += vctObj.get(i).getDistance() + ",\n";
			    sb.append(strSb);
		    }
	    } 
	    String strFileName = "热点经纬度核查表.csv";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
	    globa.closeCon();
	    
%>
<%@ include file="../include/jsp/footer.jsp"%>
